#include<bits/stdc++.h>
using namespace std;
const int N=200005;
inline int read(){
    int k=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        k=k*10+ch-'0';
        ch=getchar();
    }
    return k*f;
}
int t,n,m,a[N],c[N],x0,x1,x2,x3;
int main(){
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i) a[i]=read();
    for(int i=1;i<=m;++i) c[i]=read();
    scanf("%d",&t);
    while(t--){
        scanf("%d%d%d%d",&x0,&x1,&x2,&x3);
        printf("1");
        cout<<endl;
    }
    return 0;
}
